<%--
  Created by IntelliJ IDEA.
  User: 20426
  Date: 2020/7/22
  Time: 22:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>退票申请详情</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/back/layuiadmin/layui/css/layui.css" media="all">
</head>
<body>
<div class="layui-form"> <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
    <div class="layui-form-item">
        <label class="layui-form-label">退票申请号</label>
        <div class="layui-input-block">
            <input disabled type="text" id="refundId" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">订单号</label>
        <div class="layui-input-block">
            <input disabled type="text" id="ordersId" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户</label>
        <div class="layui-input-block">
            <input disabled type="text" id="accountName" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">退单内容</label>
        <div class="layui-input-block">
            <textarea disabled placeholder="请输入内容" id="refundContent" class="layui-textarea"></textarea>        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">退单时间</label>
        <div class="layui-input-block">
            <input disabled type="text" id="refundTime" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">退单金额</label>
        <div class="layui-input-block">
            <input disabled type="text" id="refundPrice" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" id="submit_button">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="agree">同意</button>
        </div>
    </div>
</div>

<script src="${pageContext.request.contextPath}/back/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '${pageContext.request.contextPath}/back/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['form'], function(){
        var $ = layui.$,form = layui.form;
        $.ajax({
            url:"${pageContext.request.contextPath}/back/refund/${param.refundId}"
            ,success:function(result){
                $("#refundId").val(result.refundId);
                $("#ordersId").val(result.orders.ordersId);
                $("#refundContent").val(result.refundContent);
                $("#refundPrice").val(result.refundPrice);
                $("#refundTime").val(result.refundTime);
                $("#accountName").val(result.orders.account.accountName);
                if(result.refundStatus == 1){
                    $("#submit_button").html("<h2 class='layui-btn layui-btn-warm' style='margin-left:30px;'>已同意</h2>");
                }

            },
            error:function(){}
        });

        form.on('submit(agree)',function(){
            $.ajax({
                url:"${pageContext.request.contextPath}/back/refund/${param.refundId}"
                ,type:"put"
                ,success:function(result) {
                    if (result) {
                        layer.msg("操作成功");
                        $("#submit_button").html("<h2 class='layui-btn layui-btn-warm' style='margin-left:30px;'>已同意</h2>");
                    } else {
                        layer.msg("操作失败");
                    }
                }
                ,error:function(){
                    layer.msg("ajax请求失败");
                }
            });
            // //当你在iframe页面关闭自身时
            // var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            // parent.layer.close(index); //再执行关闭
        });
    });
</script>
</body>
</html>
